Skip to content

feat(plugins): Add secrets-scanner plugin for credential exposure detection - #22594

Open
stevenelliottjr wants to merge 2 commits into
anthropics:mainfrom
stevenelliottjr:feature/secrets-scanner-plugin
Open

stevenelliottjr wants to merge 2 commits into
anthropics:mainfrom
stevenelliottjr:feature/secrets-scanner-plugin

Conversation

@stevenelliottjr

Copy link
Copy Markdown

Summary

This PR adds a secrets-scanner plugin that provides real-time detection of exposed secrets in Claude Code output, warning users immediately when sensitive data is detected.

Addresses Issues:

  • #18223 - Claude displayed sensitive .env credentials
  • #22548 - Auto-mask API keys in VS Code extension
  • #21528 - Environment Variable Redaction for Hook Security

Why This Plugin?

When Claude Code reads files or executes commands, sensitive credentials can be exposed in:

  • Terminal output (visible to anyone watching)
  • Terminal history (persisted in shell history)
  • Claude's cached tool results (~/.claude/projects/)

This plugin provides defense-in-depth by scanning all tool output and alerting users immediately.

Features

Feature Description
35+ Secret Patterns API keys, tokens, private keys, connection strings
Severity Levels Critical, high, medium, low
Major Providers AWS, Google, GitHub, Stripe, Slack, OpenAI, Anthropic
Database Strings PostgreSQL, MySQL, MongoDB, Redis with embedded creds
Private Keys RSA, SSH, PGP, EC key headers
Sensitive Files Warns on .env, credentials, .pem, etc.
Security Logging Logs detections without persisting actual secrets
Graceful Handling Never blocks operations on errors

Example Warning

============================================================
🔐 SECRETS DETECTED IN OUTPUT
============================================================

🚨 CRITICAL:
   • Stripe Secret Key - Stripe live secret key
   • AWS Access Key ID - AWS access key ID

⚠️  HIGH:
   • GitHub Token (Classic) - GitHub personal access token

Source: .env

⚡ RECOMMENDED ACTIONS:
   1. Do NOT share this terminal output
   2. Clear terminal history: `history -c`
   3. Rotate exposed credentials immediately
   4. Check ~/.claude/projects/ for cached data
============================================================

Test plan

  • Python syntax validation
  • OpenAI API key detection
  • AWS Access Key ID and Secret detection
  • GitHub token detection (classic and fine-grained)
  • Stripe live/test key detection
  • PostgreSQL connection string detection
  • RSA private key detection
  • JWT detection
  • Sensitive file path warning (.env.local)
  • Clean output (no false positives)
  • Edge cases: empty, null, malformed input
  • Security logs created correctly (without secret values)

About the Author

I'm a CIO with 19 years of experience implementing AI in regulated environments (HIPAA, SOC 2, ERISA). This plugin addresses real security concerns I've encountered deploying AI coding tools in enterprise settings.


🤖 Generated with Claude Code

…ection

Addresses issues:
- anthropics#18223: Claude displayed sensitive .env credentials
- anthropics#22548: Auto-mask API keys in VS Code extension
- anthropics#21528: Environment Variable Redaction for Hook Security

This plugin provides real-time detection of exposed secrets in Claude Code
output, warning users immediately when sensitive data is detected.

Features:
- Detects 35+ secret patterns (API keys, tokens, private keys, connection strings)
- Severity levels: critical, high, medium, low
- Covers major providers: AWS, Google, GitHub, Stripe, Slack, OpenAI, Anthropic
- Detects database connection strings with embedded credentials
- Identifies private key headers (RSA, SSH, PGP, EC)
- Warns when accessing sensitive file paths (.env, credentials, etc.)
- Security logging without persisting actual secret values
- Graceful error handling (never blocks operations)

Tested patterns:
- AWS Access Key ID and Secret Access Key
- GitHub tokens (classic and fine-grained)
- Stripe live/test keys
- PostgreSQL/MySQL/MongoDB connection strings
- RSA/SSH private keys
- JWTs and Bearer tokens

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…h filter

Fixed bug where sensitive file paths (.env, credentials, etc.) were not
being detected when file content was short (<20 chars).

Now checks file path sensitivity BEFORE applying content length filter,
ensuring warnings are shown even for small config files.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@mrmrcode

Copy link
Copy Markdown

@claude please review this

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants